<!DOCTYPE html>
<html>
<head lang="en">
    <meta charset="UTF-8">
    <title>我的账号</title>
    <meta content="width=device-width, initial-scale=1.0, maximum-scale=1.0, user-scalable=0" name="viewport" />
    <meta content="black" name="apple-mobile-web-app-status-bar-style" />
    <meta content="telephone=no" name="format-detection" />
    <link href="../../css/index.css" rel="stylesheet" type="text/css">
    <link href="../../css/mine.css" rel="stylesheet" type="text/css">
    <script src="../../js/jquery-1.8.3.min.js"></script>
    <script src="../../js/layer/layer.js"></script>
</head>
<body>
<div class="viewport">
    <div class="header">
       <div class="header-1">
           <a href="javascript:void(0)" id="join" class="header-2">
              <span id="account" class="account"></span>&nbsp;&nbsp;<span id="deptName" class="deptName"></span>
           </a>
           <a href="javascript:void(0)" class="back" id="back">返回</a>
           <span class="span-num main">WOP11000</span>
       </div>
    </div>
    <script type="text/javascript">$("#back").hide();</script>
    <div class="content m-top">
        <div class="content-1">
            <div class="blank-1"></div>
            <div class="content-1-1">
                <img id="img" alt="" src="../../images/tou.png" class="tou">
                <div class="content-1-a">
                    <span><span>昵称:</span><span id="nic"></span></span><br/>
                    <span><span>账号:</span><span id="atu"></span></span>
                </div>
                <div class="content-1-b" id="img-code">
                    <img alt="" src="../../images/b45.png" class="img-code"><br/>
                    <span>二维码名片</span>
                </div>
            </div>
        </div>
        <div class="blank-1"></div>
        <div class="content-2">
            <a href="javascript:void(0)" class="content-2-1" id="personal">
                <img alt="" src="../../images/b98.png" class="img-1"><span class="span-1">个人资料</span><img src="../../images/b49.png" class="img-2">
            </a>
        </div>
        <div class="blank"></div>
        <div class="content-2" id="w-login">
            <a href="javascript:void(0)" class="content-2-1" id="weLogin">
                <img alt="" src="../../images/b99.png" class="img-1"><span class="span-1">登录绑定</span><img src="../../images/b49.png" class="img-2">
            </a>
        </div>
        <div class="blank" id="w-blank"></div>
        <div class="content-2">
            <a href="javascript:void(0)" class="content-2-1" id="safe">
                <img alt="" src="../../images/b100.png" class="img-1"><span class="span-1">账号与安全</span><img src="../../images/b49.png" class="img-2">
            </a>
        </div>
        <div class="blank"></div>
        <div class="content-2">
            <a href="javascript:void(0)" class="content-2-1" id="identity">
                <img alt="" src="../../images/b101.png" class="img-1"><span class="span-1">身份验证</span><img src="../../images/b49.png" class="img-2">
            </a>
        </div>
        <div class="blank"></div>
        <div class="content-2">
            <a href="" class="content-2-1" id="company">
                <img alt="" src="../../images/market.png" class="img-1"><span class="span-1">公司单位</span><img src="../../images/b49.png" class="img-2">
            </a>
        </div>
        <div class="blank"></div>
    </div>
</div>
</body>
<script type="text/javascript">
    /*错误提示*/
    /*$(function(){
        var error = "${requestScope.returnMsg}";
        if(error != "" && error != "成功!"){
            layer.msg(error,{shadeClose:true,shade:0.1,time:2000});
        }
    });*/
    /*识别浏览器*/
    $(function(){
        var ua = window.navigator.userAgent.toLowerCase();
        if(ua.match(/MicroMessenger/i) == 'micromessenger'){
            /*微信自动登录*/
            layer.load();
            $.ajax({
                url:"/wape-web/api/core/centerService",
                dataType:"json",
                data:{
                    serviceCode:"1001W01",
                    code:"<%=code %>"
                },
                complete:function(xhr,status){
                    var openId = xhr.responseText.replace(/(\n)+|(\r\n)+/g, "");
                    if(openId == "null" || openId == ""){
                        layer.closeAll();
                        window.location.href="/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=mine&prefix=3g_mine&entrance=yes";
                    }
                    else{
                    	$.ajax({
                            type:"post",
                            url:"/wape-web/api/core/centerService",
                            data:{
                                serviceCode:"1001W02",
                                sign: 'web',
                                timestamp: 'web',
                                nonce: 'web',
                                editUser: 'web',
                                editTime: 'web',
                                device: 'web',
                                ipaddr: 'web',
                                mac: 'web',
                                openId:openId
                            },
                            success:function(data){
                                var wechat = eval("("+data+")");
                                if(wechat.returnCode == "200"){
                                    layer.closeAll();
                                    if(wechat.result.realName != ""){
                                        $("#account").text(wechat.result.realName);
                                    }
                                    else if(wechat.result.realName == ""){
                                        $("#account").text("您还未登录哦！");
                                    }
                                    $("#weLogin").click(function(){
                                    	layer.msg("您已登录成功，无需再次绑定！",{shadeClose:true,shade:0.1,time:2000});
                                    });
                                    $("#compNickName").text(wechat.result.companyNickName);
                                    $("#deptName").text(wechat.result.departmentName);
                                    $("#nic").text(wechat.result.nickName);
                                    $("#atu").text(wechat.result.atUserId);
                                    if(wechat.result.thumbnail != ""){
                                        $("#img").attr("src",wechat.result.thumbnail);                     
                                    }
                                    var personal = "/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=join&prefix=3g_mine&openId="+openId+ "&isWX=yes";
                                    $("#personal").attr("href",personal);
                                    var safe = "/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=account&prefix=3g_mine&openId="+openId+ "&isWX=yes";
                                    $("#safe").attr("href",safe);
                                    var identity = "/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=authentication&prefix=3g_mine&openId="+openId+ "&isWX=yes";
                                    $("#identity").attr("href",identity);
                                    $("#company").attr("href","/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=company&prefix=3g_company&entrance=yes");
                                }
                                else{
                                    layer.closeAll();
                                    var loginPath = "/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=w-login&prefix=we&openId=" + openId + "&isWX=yes" 
                                    $("#weLogin").attr("href",loginPath);
                                    $("#account").text("您还未登录哦！");
                                    $("#personal").click(function(){
                                    	layer.msg("您还未登录哦！",{shadeClose:true,shade:0.1,time:2000});
                                    });
                                    $("#safe").click(function(){
                                    	layer.msg("您还未登录哦！",{shadeClose:true,shade:0.1,time:2000});
                                    });
                                    $("#identity").click(function(){
                                    	layer.msg("您还未登录哦！",{shadeClose:true,shade:0.1,time:2000});
                                    });
                                    layer.msg("您未绑定农商号，请登录绑定！",{shadeClose:true,shade:0.1,time:2000});
                                }
                            }
                        });
                    }
                }
            });

        }else{
            $("#w-login").hide();
            $("#w-blank").hide();
            $("#personal").attr("href","/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=join&prefix=3g_mine");
            $("#safe").attr("href","/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=account&prefix=3g_mine");
            $("#identity").attr("href","/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=authentication&prefix=3g_mine");
            $("#company").attr("href","/wape-web/api/core/centerService?serviceCode=WJ9999&targetURL=company&prefix=3g_company");
        }
    });
    /*二维码*/
    $(function(){
        $("#img-code").click(function(){
            var erCode = "${user.rqCode}";
            if(erCode == ""){
                layer.msg("二维码名片未设置",{shadeClose:true,shade:0.1,time:2000});
            }
            else if(erCode != ""){
                layer.open({
                    type: 1,
                    title:false,
                    shadeClose: true,
                    closeBtn: 0,
                    shade: 0.2,
                    area: ['200px', '200px'],
                    content: "<img src='http://user.accecard.com/upload/${user.rqCode}' style='width:100%;'>"
                });
            }
        });
    });
</script>

</html>
